Problem: Find the nonconstant polynomial $P(x)$ such that
\[P(P(x)) = (x^2 + x + 1) P(x).\]
Solution: Let $d$ be the degree of $P(x).$  Then the degree of $P(P(x))$ is $d^2,$ and the degree of $(x^2 + x + 1) P(x)$ is $d + 2,$ so
\[d^2 = d + 2.\]Then $d^2 - d - 2 = (d - 2)(d + 1) = 0.$  Since $d$ is positive, $d = 2.$

Let $P(x) = ax^2 + bx + c.$  Then
\begin{align*}
P(P(x)) &= a(ax^2 + bx + c)^2 + b(ax^2 + bx + c) + c \\
&= a^3 x^4 + 2a^2 bx^3 + (ab^2 + 2a^2 c + ab) x^2 + (2abc + b^2) x + ac^2 + bc + c
\end{align*}and
\[(x^2 + x + 1)(ax^2 + bx + c) = ax^4 + (a + b) x^3 + (a + b + c) x^2 + (b + c) x + c.\]Comparing coefficients, we get
\begin{align*}
a^3 &= a, \\
2a^2 b &= a + b, \\
ab^2 + 2a^2 c + ab &= a + b + c, \\
2abc + b^2 &= b + c, \\
ac^2 + bc + c &= c.
\end{align*}From $a^3 = a,$ $a^3 - a = a(a - 1)(a + 1) = 0,$ so $a$ is 0, 1, or $-1.$  But $a$ is the leading coefficient, so $a$ cannot be 0, which means $a$ is 1 or $-1.$

If $a = 1,$ then $2b = 1 + b,$ so $b = 1.$  Then
\[1 + 2c + 1 = 1 + 1 + c,\]so $c = 0.$  Note that $(a,b,c) = (1,1,0)$ satisfies all the equations.

If $a = -1,$ then $2b = -1 + b,$ so $b = -1.$  Then
\[-1 + 2c + 1 = -1 - 1 + c,\]so $c = -2.$  But then the equation $ac^2 + bc + c = c$ is not satisfied.

Hence, $(a,b,c) = (1,1,0),$ and $P(x) = \boxed{x^2 + x}.$